from django.shortcuts import render
from django.http import HttpResponse
# 引入SQL引擎
#from django.db import connection

from myErp.redis_pool import POOL
from myErp.mysql_pool import MysqlDB
import redis


def index(request):
    return HttpResponse('hello,index')

def zhuge(request):

    return  render(request,'1019.html')

def admin(request):
    conn =  redis.Redis(connection_pool=POOL)
    key = conn.keys()[0].decode('utf-8')
    url = conn.hget(key,'age')
    print(url)
    return render(request,'admin.html',{'admin':1231231232132112})


def apis(request):
    cursor = MysqlDB()

    # sql  = "" \
    #        "" \
    #        "create table testok1(" \
    #        "`id`  int(200) auto_increment  primary key  COMMENT 'ID',"\
    #        "`name` varchar(10) comment '名称')"
    res = cursor.runsql("select * from auth_permission where mysq=213;")
    print(res)
    return render(request, 'admin.html', {'admin': res})


def login(request):
    return render(request, 'login.html', {'admin': 'login'})


def logintest(request):
    if request.POST.get('user'):
        return HttpResponse('123')
    return None


def temp(request):
    return render(request,'temp.html',{'title':'hello'})